package com.lwj.vo;


import com.github.pagehelper.Page;
import com.lwj.vo.system.DictionaryCategoryVo;

import java.io.Serializable;
import java.util.List;

public class PageBean<T> implements Serializable {
    //页码
    private Integer pageNumber;
    //页面数据条目
    private Integer pageSize;
    //总页数
    private Integer totalPages;
    //总条目
    private Integer totalSize;
    //数据
    private List<T> data;

    public Integer getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(Integer pageNumber) {
        this.pageNumber = pageNumber;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(Integer totalPages) {
        this.totalPages = totalPages;
    }

    public Integer getTotalSize() {
        return totalSize;
    }

    public void setTotalSize(Integer totalSize) {
        this.totalSize = totalSize;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public PageBean() {
    }

    public PageBean(Integer pageNumber, Integer pageSize, Integer totalPages, Integer totalSize, List<T> data) {
        this.pageNumber = pageNumber;
        this.pageSize = pageSize;
        this.totalPages = totalPages;
        this.totalSize = totalSize;
        this.data = data;
    }

    public static <T> PageBean<T> page(Page<T> page){
        List<T> data = page.getResult();
        int pageSize = page.getPageSize();
        int pageNum = page.getPageNum();
        int total =(int) page.getTotal();
        int pages = page.getPages();
        return new PageBean<T>(pageNum,pageSize,pages,total,data);
    }
}

